#include "gamebackground.h"

GameBackground::GameBackground(QGraphicsScene *scene)
    : QGraphicsPixmapItem()
{
    scene->addItem(this);
    setData(ITEM_TYPE,GameItems::BaseBackgound);

    xSpeed = 0;
    ySpeed = 0;
}

GameBackground::GameBackground(QPixmap pixmap, QGraphicsScene *scene)
    : QGraphicsPixmapItem(pixmap)
{
    setPixmap(pixmap);
    scene->addItem(this);
    setData(ITEM_TYPE,GameItems::BaseBackgound);

    xSpeed = 0;
    ySpeed = 0;
}

void GameBackground::setSpeed(qreal x, qreal y)
{
    xSpeed = x;
    ySpeed = y;
}

qreal GameBackground::speedX()
{
    return xSpeed;
}

qreal GameBackground::speedY()
{
    return ySpeed;
}

void GameBackground::advance(int phase)
{
    if (phase == 0)
            moveBy(xSpeed,ySpeed);
}

void GameBackground::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    emit backgroundClicked(event->scenePos());
}
